package com.hb.trade.api.manager.controller;

import cn.hutool.core.util.StrUtil;
import com.hb.core.pojo.project.portal.dto.PortalNoticeDTO;
import com.hb.trade.client.project.PortalNoticeClient;
import io.swagger.annotations.Api;
import org.fzzn.core.model.msg.ResponseDto;
import org.fzzn.core.util.MsgUtil;
import org.fzzn.core.util.ResultUtil;
import org.fzzn.core.web.anno.Version;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 接受私有化推送信息的接口
 *
 * @author tian
 * @date 2022年06月29日 10:20
 */
@Version(1.0)
@RequestMapping("/{version}")
@RestController
public class ApiPortalNoticeByPushController {

    protected PortalNoticeClient portalNoticeClient;

    public ApiPortalNoticeByPushController(PortalNoticeClient portalNoticeClient){
        this.portalNoticeClient = portalNoticeClient;
    }
    /**
     * 接受私有化推送信息的接口
     *
     * @author tian
     * @date 2022-6-29 10:22
     * @param portalNoticeDTO
     * @return org.fzzn.core.model.msg.ResponseDto
     */
    @PostMapping("/portalNotice/saveByPush")
    public ResponseDto saveByPush(@RequestBody PortalNoticeDTO portalNoticeDTO) {
        String paramsValid = portalNoticeDTO.paramsValid();
        if (StrUtil.isNotEmpty(paramsValid)) {
            return ResultUtil.fail(paramsValid);
        }
        portalNoticeClient.savePortalNotice(portalNoticeDTO);
        return ResultUtil.msg(MsgUtil.success());
    }

}
